<template>
		<view class="content" :style="{'background':kbackgroundColor}" style="min-height: 100vh">
		<hx-navbar title="数字科技商品" :back="true" :fixed="false" :color="knavTitleColor" barPlaceholder="hidden" transparent="auto">
		</hx-navbar>

		<!-- <view class="container">
			<view class="tab_box2">
				<view class="tab_item2 " style="width: auto;" :class="{tab_on2:current_cate == 1}" :style="current_cate == 1? [selStyle]:[tabNormaleStyle]" @tap="tap_cate(1)">
					数字版权商品
				</view>
				<view class="tab_item2" :class="{tab_on2:current_cate == 2}" :style="current_cate == 2? [selStyle]:[tabNormaleStyle]" @tap="tap_cate(2)">
					盲盒
				</view>
			</view>
		</view> -->
		
		
		<!-- 		<view class="search cell-item-ft">
			<view class="search-box">
				<n-icon name="search" color="#333"></n-icon>
				<input v-model="keyword" class="search-input" placeholder="搜索藏品" placeholder-class="color-9 fsz28"
					type="text">
				<view class="btn-search" @click="get_data_list()">
					搜索
				</view>
			</view>
		</view> -->
		<!-- <tab-box :tab_list="status_list" :current_tab="tab_id" rang_key="name" @onTabClick="tap_status"></tab-box> -->
		<view class="goods_list">
			<view class="goods_item" :style="{'background': (ktheme == 'purple' ? '#ffffff': '#191919')}" @tap="show_nums(item)" v-for="item,id in list" :key="id">
				<image :src="item.image" mode="aspectFit" class="goods_img"></image>
				<view class="goods_info" :class="ktheme == 'black' ? 'black-info' : 'white-info'">
					<view class="goods_name">
						<view style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" :style="{'color': knormalColor}">{{item.name}}</view>
						<n-icon size="20" name="triangledownfill" color="#333"></n-icon>
					</view>
					<view class="goods_num">
						共<text  :style="{color:knormalColor}">{{item.ownQuantity}}</text>个
					</view>
				</view>
			</view>
			<view class="none_box" v-if="list.length==0">
				<image  src="@/static/without.png" mode="widthFix"></image>
			</view>
		</view>
		<view class="" style="height: 130rpx;"></view>
		<!-- <image src="../../static/user/go_mart_btn.png" @tap="go_mart" mode="widthFix" class="go_mart"></image> -->

		<uni-popup ref="collect_list" type="bottom">
			<view class="collect_box" :style="{background:ktabbarBgColor}">
				<view class="collect_name" :style="{color:knormalColor}">
					{{nums_name}}
					<view class="collect_num">
						/共<text style="color: #141519;" :style="{color:knormalColor}">{{nums_count}}</text>个
					</view>
				</view>
				<view class="tips">
					默认按最新收藏时间排序
				</view>

				<view class="collect_list">
					<view class="collect_item" :style="{border:kborderSty,background:kcellBgColor}" v-for="item, id in nums_list" :key="id" @tap="go_detail(item.nftId)">
						<view class="" style="display: flex;align-items: center;">
							<view class="">
								<image :src="item.item.image" class="collect_image" mode=""></image>
							</view>
							<view class="" style="margin-left: 14rpx;">
								<view class="collect_price">
									#{{item.tokenId}}
								</view>
								<!-- <view class=""
									style="width: 100%;display: flex;height: 50rpx;justify-content: space-around;">
									<view class="collect_price">
										￥{{item.price|fp}}
									</view>
								</view> -->
							</view>
						</view>
						<view class="collect_code" style="">
							购入时间:{{item.getTime|filterTime}}
						</view>
						<view class="status" :style="{background:kselectColorSize}">
							<view class="" v-if="item.status===1">
								转售中
							</view>
							<view class="" v-if="item.status===0">
								收藏中
							</view>
						</view>
					</view>

				</view>
				<view class="see_more" @tap="next_page">
					{{nums_hasNextPage?'查看更多':'没有更多了'}}
				</view>
			</view>
		</uni-popup>
	</view>
</template>
<script>
	import tabbarqn from '@/components/tabbarqn.vue'
	export default {
		components: {
			tabbarqn
		},
		filters: {
			filterTime(val) {
				return uni.$u.timeFormat(parseInt(val), 'yyyy-mm-dd hh:MM')
			}
		},
		data() {
			return {
				page: 1,
				limit: 10,
				hasNextPage: true,
				list: [],
				cate: false,
				current_cate: 1,
				current_status: 0,
				tab_id: 0,
				keyword: '',
				status_list: [{
						id: 1,
						name: '收藏中'
					},
					{
						id: 2,
						name: '转售中'
					},
					{
						id: 3,
						name: '已转售'
					},
				],
				nums_page: 1,
				nums_limit: 10,
				nums_hasNextPage: true,
				nums_list: [],
				nums_count: 0,
				current_id: 0,
				nums_name: '',
			}
		},
		onLoad() {
		},
		onShow: function() {
			let data = {}
			this.get_data_list();
			// this.$api.getCategory(data, res => {
			// 	if (res.status) {
			// 		this.cate = res.data;
			// 		this.get_data_list();
			// 	} else {
			// 		this.$common.errorToShow('获取出错')
			// 	}
			// })
		},
		onPullDownRefresh() {
			setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 1000)
			this.get_data_list()
		},
		onReachBottom() {
			if (this.hasNextPage) {
				let new_page = this.page + 1;
				let data = {
					pageNo: new_page,
					// limit: this.limit,
					itemType: this.current_cate,
					// status: this.current_status,
				}
				this.$api.getCollectionList(data, res => {
					if (res.status) {
						this.list = this.list.concat(res.data);
						this.hasNextPage = res.data.length >= this.limit;
						this.page = new_page
					}
				})
			}

		},

		methods: {
			go_mart: function() {
				uni.switchTab({
					url: '/pages/mart/mart'
				})
			},

			show_nums: function(item) {
				let url = `/pages/collection/collection-list?nums_count=${item.ownQuantity}&nums_name=${item.name}&iid=${item.iid}`
				uni.navigateTo({
					url:url
				})
			},
			next_page: function() {
				if (this.nums_hasNextPage) {
					let new_page = this.nums_page + 1;
					let data = {
						pageNo: new_page,
						// limit: this.nums_limit,
						iid: this.current_id,
						// status: this.current_status,
						// keyword: this.keyword
					}
					this.$api.getMyGoodsListById(data, res => {
						if (res.status) {
							this.nums_list = this.nums_list.concat(res.data);
							this.nums_hasNextPage = res.data.length >= this.nums_limit;
							this.nums_page = new_page
						}
					})
				}
			},
			get_data_list: function() {
				this.page = 1;
				this.list = []
				this.hasNextPage = true;
				let data = {
					pageNo: this.page,
					// limit: this.limit,
					itemType: this.current_cate,
					// status: this.current_status,
					// keyword: this.keyword
				}

				this.$api.getCollectionList(data, res => {
					if (res.status) {
						this.list = res.data;
						this.hasNextPage = res.data.length >= this.limit;
					}
				})
			},
			tap_status: function(id) {
				this.tab_id = id;
				let status = this.status_list[id];
				this.current_status = status.id;
				this.get_data_list()

			},
			tap_cate: function(id) {
				this.keyword = ''
				this.current_cate = id;
				this.get_data_list()
			},
			go_detail: function(sn) {
				this.$refs.collect_list.close()
				uni.navigateTo({
					url: 'collection_details?id=' + sn
				})
			}
		}
	}
</script>

<style lang="scss">
	// .search-box {
	// 	width: 100%;
	// 	display: flex;
	// 	height: 77rpx;
	// 	align-items: center;
	// 	justify-content: space-between;
	// 	padding: 0 10rpx;
	// 	background-color: #F6F6F6;
	// 	border-radius: 10rpx;
	// 	padding-left: 23rpx;

	// 	.search-input {
	// 		flex: 1;
	// 		color: #333;
	// 		margin-left: 20rpx;
	// 	}

	// 	.btn-search {
	// 		width: 110rpx;
	// 		height: 57rpx;
	// 		color: #fff;
	// 		background: #ABABAB;
	// 		line-height: 55rpx;
	// 		text-align: center;
	// 		border-radius: 10rpx;
	// 	}
	// }

	.see_more {
		width: 100%;
		padding: 20rpx 0;
		text-align: center;
		font-size: 28rpx;
		color: #ABA9B4;
	}

	.collect_box {
		width: 100%;
		border-radius: 10rpx 10rpx 0rpx 0rpx;
		background: #FFFFFF;
		min-height: 340rpx;
		padding: 30rpx 30rpx 62rpx 30rpx;

		.collect_list {
			width: 100%;
			min-height: 155rpx;
			max-height: 800rpx;
			overflow: auto;
			display: flex;
			align-items: center;
			flex-wrap: wrap;
			margin-top: 20rpx;
			justify-content: space-between;
			padding-right: 8rpx;

			.cyz {
				background-color: var(--QianmenonlyBackgournd);
			}

			.zsz {
				background-color: var(--QianmenonlyBackgournd2);
			}

			.collect_item {
				width: 48%;
				height: 175rpx;
				box-shadow: 3rpx 2rpx 6rpx 1rpx #9c9c9c;
				background: linear-gradient(234deg, #fbe3e7 0%, #fbfbfb 100%);
				border-radius: 20rpx;

				position: relative;
				padding: 15rpx;
				margin-bottom: 20rpx;

				.collect_image {
					width: 110rpx;
					height: 112rpx;
					border-radius: 20rpx;
				}

				.status {
					display: inline-block;
					padding: 2rpx 10rpx 2rpx 19rpx;
					background: #9780ff;
					border-radius: 0 20rpx 0 20rpx;
					font-size: 20rpx;
					color: #ffffff;
					position: absolute;
					top: 0;
					right: 0;
				}

				.jishoustatus {
					display: inline-block;
					padding: 2rpx 8rpx 2rpx 14rpx;

					border-radius: 20rpx;
					font-size: 18rpx;
					color: #ffffff;
					position: absolute;
					bottom: 6rpx;
					right: 0;
				}

				.collect_code {
					font-size: 20rpx;
					color: #7A7A7A;
				}

				.collect_price {
					width: 100%;
					text-align: center;
					font-size: 36rpx;
					color: #141519;
					font-weight: 600;
				}
			}
		}

		.collect_list::after {
			width: 216rpx;
			content: '';
		}

		.tips {
			padding-top: 10rpx;
			font-size: 24rpx;
			color: #ABA9B4;
		}

		.collect_name {
			display: flex;
			align-items: center;
			font-size: 36rpx;
			font-weight: bold;
			color: #141519;

			.collect_num {
				padding-left: 10rpx;
				font-size: 24rpx;
				color: #ABA9B4;
			}
		}

	}

	.go_mart {
		position: fixed;
		bottom: 30rpx;
		width: 690rpx;
		margin: 0 30rpx;
		height: 101rpx;

	}

	.goods_list {

		width: 100%;
		padding: 0 30rpx;
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		justify-content: space-between;
		position: relative;
		z-index: 1;

		.goods_item {
			position: relative;
			width: 48%;
			height: 458rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 9rpx 18rpx 0rpx rgba(156, 156, 156, 0.3);
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			margin-top: 30rpx;

			.goods_img {
				position: absolute;
				width: 100%;
				height: 100%;
				z-index: 0;
				border-radius: 20rpx;
				display: block;
			}
			.black-info{
				backdrop-filter: blur(20px);
				// box-shadow: inset 0px 0px 10px RGBA(163, 182, 101, 0.5);
			}
			.white-info{
				background: white;
			}
			.goods_info {
				position: relative;
				border-radius: 10rpx;
				position: absolute;
				left: 10rpx;
				right: 10rpx;
				bottom: 10rpx;
				padding: 20rpx 17rpx;
				// width: 100%;
				z-index: 1;
				.goods_name {
					display: flex;
					justify-content: space-between;
					align-items: center;

					font-size: 28rpx;
					font-weight: bold;
					color: #141519;
				}

				.goods_num {
					font-size: 22rpx;
					color: #999;
					padding-top: 12rpx;
				}
			}
		}

		.none_box {
			width: 534rpx;
			margin: 117rpx auto;
			font-size: 32rpx;
			color: #ABA9B4;
		}

		.none_box image {
			width: 100%;
			height: 534rpx;
			margin-bottom: 10rpx;
		}
	}




	.tab_box2 {
		width: 100%;

		height: 124rpx;
		padding: 0 30rpx;
		display: flex;
		align-items: center;
		position: relative;

		.tab_bg2 {
			width: 100%;
			position: absolute;
			bottom: 0;
			height: 283rpx;
			z-index: 0;
		}

		.tab_item2 {
			width: 98rpx;
			height: 54rpx;
			border-radius: 100rpx 100rpx 100rpx 100rpx;
			opacity: 1;
			font-size: 30rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-right: 30rpx;
			position: inherit;
			color: var(--tabNormalColor);
		}

		.tab_on2 {
			// color: $text-zdy;
			color: var(--selectColorSize);
			font-weight: bold;
		}

	}
</style>